package TestJVM;

import org.junit.jupiter.api.Test;

import java.awt.*;
import java.awt.event.KeyEvent;
import java.lang.reflect.Array;
import java.util.Arrays;
import java.util.Comparator;

/**
 * @Author Mr.Wen
 * @Version 1.0
 */
public class Test2 {
    public static void main(String[] args) {
        try {
            Robot robot = new Robot();
            robot.keyPress(KeyEvent.VK_A);
        } catch (AWTException e) {
            throw new RuntimeException(e);
        }
    }

    /**
     * 带native关键字的方法，需要链接C++代码,java作用范围达不到
     * 会进入本地方法栈
     */
    private native void start0();

    @Test
    void test1() {
        new Thread(() -> {
            System.out.println("true = " + true);
        }, "hello runnable").start();
    }

    int[] arr = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};

    /**
     * 冒泡排序
     */
    @Test
    void sortedNum() {
        for (int i = 0; i < arr.length - 1; i++) {/*比较几层*/
            for (int j = 0; j < arr.length - 1 - i; j++) {/*每层比较几次*/
                if (arr[j] < arr[j + 1]) {
                    int temp = arr[j];
                    arr[j] = arr[j + 1];
                    arr[j + 1] = temp;
                }
            }
        }
        System.out.println(Arrays.toString(arr));
    }

}
